<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改项目信息')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-post-edit" th:object="${oneItem}">
        <input id="contentId" name="contentId" type="hidden" th:field="*{projectId}"/>
        <div class="form-group">
            <label class="col-sm-3 control-label ">项目名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" disabled="disabled" name="projectName" id="projectName"
                       th:field="*{projectName}" required>
            </div>
        </div>
        <!--订单表的数据-->
        <div class="form-group">
            <label class="col-sm-3 control-label">订单编号：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" disabled="disabled" name="orderNumber" id="orderNumber"
                       th:field="*{orderNumber}" required>
            </div>
        </div>
        <!--员工表的数据-->
        <div class="form-group">
            <label class="col-sm-3 control-label">项目负责人：</label>
            <!--查表！-->
            <div class="col-sm-8">
                <select class="form-control" name="leaderId">
                    <option th:each="staffTable:${staffList}" th:value="${staffTable.staffId}"
                            th:selected="${staffTable.staffId eq oneItem.leaderId}">[[${staffTable.staffName}]]
                    </option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">项目金额：</label>
            <div class="col-sm-8" th:if="${oneItem.projectMoney} ne null">
                <input id="projectMoney" name="projectMoney" class="form-control" th:field="*{projectMoney}"/>
            </div>
            <div class="col-sm-8" th:if="${oneItem.projectMoney} eq null">
                <input name="projectMoney" class="form-control"/>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">项目类型：</label>
            <div class="col-sm-8" th:if="${oneItem.projectCategory} ne null">
                <input id="projectCategory" name="projectCategory" class="form-control" th:field="*{projectCategory}"/>
            </div>
            <div class="col-sm-8" th:if="${oneItem.projectCategory} eq null">
                <input name="projectCategory" class="form-control"/>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">项目周期：</label>
            <div class="col-sm-8">
                <input id="projectPeriod" name="projectPeriod" class="form-control" th:field="*{projectPeriod}"/>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">项目状态：</label>
            <div class="col-sm-8" th:if="${oneItem.projectState} ne null">
                <input id="projectState" name="projectState" class="form-control" th:field="*{projectState}"/>
            </div>
            <div class="col-sm-8" th:if="${oneItem.projectState} eq null">
                <input name="projectState" class="form-control"/>
            </div>
        </div>
        <!--顾客表-->
        <div>客户信息部分
            <!--注释部分通过客户名称回写-->
            <div class="form-group">
                <label class="col-sm-3 control-label">客户编号：</label>
                <div class="col-sm-8">
                    <input id="clientId" name="clientId" class="form-control" th:value="${client.clientId}"
                           disabled="disabled"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">客户名称：</label>
                <div class="col-sm-8">
                    <input id="clientName" name="clientName" class="form-control" th:value="${client.clientName}"
                           disabled="disabled"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">客户类型：</label>
                <div class="col-sm-8">
                    <input id="clientType" name="clientType" class="form-control" th:value="${client.clientType}"
                           disabled="disabled"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">联系人：</label>
                <div class="col-sm-8">
                    <input id="clientContact" name="clientContact" class="form-control"
                           th:value="${client.clientContact}" disabled="disabled"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">职位：</label>
                <div class="col-sm-8">
                    <input id="clientPosition" name="clientPosition" class="form-control"
                           th:value="${client.clientPosition}" disabled="disabled"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">联系方式：</label>
                <div class="col-sm-8">
                    <input id="clientPhoneNumber" name="clientPhoneNumber" class="form-control"
                           th:value="${client.clientPhoneNumber}" disabled="disabled"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input id="clientRemark" name="clientRemark" class="form-control" th:value="${client.clientRemark}"
                           disabled="disabled"/>
                </div>
            </div>
        </div>
        <div>订单信息-项目内容
            <div class="form-group">
                <label class="col-sm-3 control-label">项目内容：</label>
                <div class="col-sm-8">
                    <input id="projectContent" th:field="*{projectContent}" name="projectContent" class="form-control"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">项目风格：</label>
                <div class="col-sm-8">
                    <input id="projectStyle" th:field="*{projectStyle}" name="projectStyle" class="form-control"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">项目类型：</label>
                <div class="col-sm-8">
                    <input id="projectType" th:field="*{projectType}" name="projectType" class="form-control"/>
                </div>
            </div>
            <!--<div class="form-group">-->
            <!--<label class="col-sm-3 control-label">项目订立时间：</label>-->
            <!--<div class="col-sm-8">-->
            <!--<input id="projectStartTime" name="projectStartTime" class="form-control"/>-->
            <!--</div>-->
            <!--</div>-->
            <!--<div class="form-group">-->
            <!--<label class="col-sm-3 control-label">项目完成时间：</label>-->
            <!--<div class="col-sm-8">-->
            <!--<input id="projectEndTime" name="projectEndTime" class="form-control"/>-->
            <!--</div>-->
            <!--</div>-->
            <div class="form-group">
                <label class="col-sm-3 control-label">项目订立时间和完成时间</label>
                <div class="col-sm-8 input-daterange input-group">
                    <input type="text" class="input-sm form-control" name="projectStartTime" id="laydate-startTime"
                           placeholder="yyyy-MM-dd" th:value="${convertTime.projectStartTime}"/>
                    <span class="input-group-addon">到</span>
                    <input type="text" class="input-sm form-control" name="projectEndTime" id="laydate-endTime"
                           placeholder="yyyy-MM-dd" th:value="${convertTime.projectEndTime}"/>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input id="projectRemark" th:field="*{projectRemark}" name="projectRemark" class="form-control"/>
                </div>
            </div>
        </div>

        <div th:if="${orderProduct.productId} ne -1">订单信息——产品清单
            <div class="form-group">
                <label class="col-sm-3 control-label">产品编号：</label>
                <div class="col-sm-8">
                    <input id="productId" th:field="${orderProduct.productId}" name="productId" class="form-control"
                           disabled="disabled"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">产品名称：</label>
                <div class="col-sm-8">
                    <input id="productName" th:field="${orderProduct.productName}" name="productName"
                           class="form-control" disabled="disabled"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">数量：</label>
                <div class="col-sm-8">
                    <input id="productNumber" th:field="${orderProduct.productNumber}" name="productNumber"
                           class="form-control" disabled="disabled"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">单位：</label>
                <div class="col-sm-8">
                    <input id="productUnit" th:field="${orderProduct.productUnit}" name="productUnit"
                           class="form-control" disabled="disabled"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">单价（元/个）：</label>
                <div class="col-sm-8">
                    <input id="productUnitPrice" th:field="${orderProduct.productUnitPrice}"
                           name="productUnitPrice" class="form-control" disabled="disabled"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">总额：</label>
                <div class="col-sm-8">
                    <input id="productAllPrice" th:field="${orderProduct.productAllPrice}" name="productAllPrice"
                           class="form-control" disabled="disabled"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input id="remarks" th:field="${orderProduct.remarks}" name="remarks" class="form-control"
                           disabled="disabled"/>
                </div>
            </div>
        </div>

        <div th:if="${orderProduct.productId} eq -1">订单信息——产品清单
            <div class="form-group">
                <label class="col-sm-3 control-label">产品编号：</label>
                <div class="col-sm-8">
                    <input ame="productId" class="form-control" disabled="disabled"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">产品名称：</label>
                <div class="col-sm-8">
                    <input name="productName" class="form-control" disabled="disabled"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">数量：</label>
                <div class="col-sm-8">
                    <input name="productNumber" class="form-control" disabled="disabled"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">单位：</label>
                <div class="col-sm-8">
                    <input name="productUnit" class="form-control" disabled="disabled"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">单价（元/个）：</label>
                <div class="col-sm-8">
                    <input name="productUnitPrice" class="form-control" disabled="disabled"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">总额：</label>
                <div class="col-sm-8">
                    <input name="productAllPrice" class="form-control" disabled="disabled"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="remarks" class="form-control" disabled="disabled"/>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">附加信息：</label>
            <div class="col-sm-8">
                <textarea id="projectAddInfo" name="projectAddInfo" class="form-control">[[*{projectRemark}]]</textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<script type="text/javascript">
    var prefix = ctx + "cyq/item/item";

    $("#form-post-edit").validate({
        onkeyup: false,
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-post-edit').serialize());
        }
    }

    $(function () {
        $("#datetimepicker-startTime").datetimepicker({
            format: 'yyyy-mm-dd',
            minView: "month",
            todayBtn: true,
            autoclose: true,
            endDate: new Date(),
        }).on('changeDate', function (event) {
            event.preventDefault();
            event.stopPropagation();
            var startTime = event.date;
            $('#datetimepicker-endTime').datetimepicker('setStartDate', startTime);
        });

        $("#datetimepicker-endTime").datetimepicker({
            format: 'yyyy-mm-dd',
            minView: "month",
            todayBtn: true,
            autoclose: true,
            endDate: new Date(),
        }).on('changeDate', function (event) {
            event.preventDefault();
            event.stopPropagation();
            var endTime = event.date;
            $("#datetimepicker-startTime").datetimepicker('setEndDate', endTime);
        });

        <!-- laydate示例 -->
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            var startDate = laydate.render({
                elem: '#laydate-startTime',
                max: $('#laydate-endTime').val(),
                theme: 'molv',
                trigger: 'click',
                done: function (value, date) {
                    // 结束时间大于开始时间
                    if (value !== '') {
                        endDate.config.min.year = date.year;
                        endDate.config.min.month = date.month - 1;
                        endDate.config.min.date = date.date;
                    } else {
                        endDate.config.min.year = '';
                        endDate.config.min.month = '';
                        endDate.config.min.date = '';
                    }
                }
            });

            var endDate = laydate.render({
                elem: '#laydate-endTime',
                min: $('#laydate-startTime').val(),
                theme: 'molv',
                trigger: 'click',
                done: function (value, date) {
                    // 开始时间小于结束时间
                    if (value !== '') {
                        startDate.config.max.year = date.year;
                        startDate.config.max.month = date.month - 1;
                        startDate.config.max.date = date.date;
                    } else {
                        startDate.config.max.year = '';
                        startDate.config.max.month = '';
                        startDate.config.max.date = '';
                    }
                }
            });
        });
    });
</script>
</body>
</html>
